package com.fengycx.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fengycx.pojo.domain.CustomerCar;
import com.fengycx.mapper.CustomerCarMapper;
import com.fengycx.service.ICustomerCarService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 客户车辆 服务实现类
 * </p>
 *
 * @author Cino
 * @since 2024-02-23
 */
@Service
public class CustomerCarServiceImpl extends ServiceImpl<CustomerCarMapper, CustomerCar> implements ICustomerCarService {


    @Override
    public void addCar(CustomerCar customerCar) {
        customerCar.setCreateTime(new Date());
        customerCar.setCustomerId(StpUtil.getLoginIdAsLong());
        customerCar.setVersion(0);
        customerCar.setDeleted(false);
        super.save(customerCar);
    }


    @Override
    public List<CustomerCar> getCustomerCarList() {
        return super.list(new LambdaQueryWrapper<CustomerCar>().eq(CustomerCar::getCustomerId,  StpUtil.getLoginIdAsLong()));
    }
}
